<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;

/**
 * @method static find($id)
 * @method static create(array $validated)
 * @method static where(string $string)
 * @method static withCount(string $string)
 */
class Tag extends Model
{
    use HasFactory;
    protected $table = "tb_tag";
    protected $primaryKey = "tag_id";
    public const UPDATED_AT = "tag_update_time";
    public const CREATED_AT = "tag_create_time";
    protected $fillable = ["tag_name"];

    public function posts(): BelongsToMany
    {
        return $this->belongsToMany("App\Models\Post", "tb_tag_post", "tag_id", "post_id");
    }
}
